package com.piesat.quake.business.system.model;

import com.piesat.security.service.dto.UserDto;

import java.util.Date;

/**
 * @author Gersy
 * @date 2023/3/10
 * @since 1.0
 */
public class SysUserDTO extends UserDto {
    private String regionCode;

    public SysUserDTO(String id,
                      String username,
                      String nickName,
                      String password,
                      String email,
                      String phone,
                      String gender,
                      String avatarName,
                      String avatarPath,
                      Boolean isAdmin,
                      Boolean enabled,
                      Date pwdResetTime,
                      String roleId,
                      Long maxStorageSize,
                      Integer auditState) {
        super(id, username, nickName, password, email, phone, gender, avatarName, avatarPath, isAdmin, enabled, pwdResetTime, roleId, maxStorageSize, auditState);
    }

    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    public static SysUserDTO convertFrom(SysUser user, SysRole role) {
        SysUserDTO sysUserDTO = new SysUserDTO(user.getUserId(), user.getUsername(), user.getNickName(), user.getPassword(), user.getEmail(), user.getPhone(), user.getGender(), user.getAvatarName(), user.getAvatarPath(), user.getIsAdmin(), user.getEnabled(), user.getPwdResetTime(), user.getRoleId(), role == null ? 0L : 0L, user.getAuditState());
        sysUserDTO.regionCode = user.getRegionCode();
        return sysUserDTO;
    }

}
